#include <stdio.h>
#include <string.h>
#define SIZE 2
struct Book getInput(struct Book);
void printBook(struct Book);

struct Date{
	int year;
	int month;
	int day;
};

struct Book{
	char title[128];
	char author[40];
	float price;
	struct Date date;
	char publisher[40];
};

struct Book getInput(struct Book book){
	printf("请输入书名:\n");
//	scanf("%s", book.title);
	gets(book.title);
	printf("请输入作者:\n");
//	scanf("%s", book.author);
	gets(book.author);

	printf("请输入出版社:\n");
//	scanf("%s", book.publisher);
	gets(book.publisher);

	printf("请输入售价:\n");
	scanf("%f", &book.price);
	printf("请输入出版时间:\n");
	scanf("%d-%d-%d", &book.date.year, &book.date.month, &book.date.day);
	getchar();
	return book;
}

void printBook(struct Book book){
	printf("书名:%s \n", book.title);
	printf("作者:%s \n", book.author);
	printf("售价:%.2f \n", book.price);
	printf("出版时间:%d-%d-%d \n", book.date.year, book.date.month, book.date.day);
	printf("出版社:%s \n", book.publisher);
}

int main(void){
	int i, c;
//	printf("How many books do you want to record\n");
//	scanf("%d", &number);
	struct Book book;
	struct Book bookList[SIZE];

	for(i=0 ;i<SIZE; i++){
		printf("pls input the info of %d th book\n", i+1);
		book = getInput(book);
		bookList[i] = book;
		putchar('\n');
	}

	printf("信息录入完毕\n");

	for (c=0;c<SIZE; c++){
		printf("第%d本书信息如下:\n", c+1);
		printBook(bookList[c]);
	}

	return 0;
}